package com.loklok.code.confuse.action;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.loklok.code.confuse.extension.PathConfigSettingCache;
import com.loklok.code.confuse.service.FullUpdateTemplateService;
import com.loklok.code.confuse.util.CommonUtil;
import org.jetbrains.annotations.NotNull;

/**
 * @Classname  FullUpdateFeignInfoAction
 * @Description 全量更新feign信息
 * @Date 2022/12/7 18:31
 * @author wangchangjiu
 */
public class UpdateTemplateAction extends AnAction {

    @Override
    public void actionPerformed(@NotNull AnActionEvent anActionEvent) {

        Project project = anActionEvent.getProject();

        PathConfigSettingCache state = PathConfigSettingCache.getInstance(project);
        if (state == null || state.getConfig() == null || state.getConfig().requiredFieldsEmpty()) {
            CommonUtil.configureMessageReminders(project);
            return;
        }
        FullUpdateTemplateService.updateTemplate(anActionEvent, state.getConfig());
    }
}